function CGrids=getCompGrids(obj)

% This file is part of CISNE.
%
%     CISNE is free software: you can redistribute it and/or modify
%     it under the terms of the GNU General Public License as published by
%     the Free Software Foundation, either version 3 of the License, or
%     any later version.
%
%     CISNE is distributed in the hope that it will be useful,
%     but WITHOUT ANY WARRANTY; without even the implied warranty of
%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%     GNU General Public License for more details.
%
%     You should have received a copy of the GNU General Public License
%     along with CISNE.  If not, see <http://www.gnu.org/licenses/>.

% Copyright 2011. Jose Maria Garcia-Valdecasas Bernal

CompGrids=[];
root=obj.m_tree.Root();
for j=0:get(root,'ChildCount')-1
    child=root.getChildAt(j);
    kind=child.getValue();
    kind=char(kind(2));
    if (strcmp(kind,'COMPUTATIONAL'))
        %CGrids found, return child
        CompGrids=child;
        break
    end
end
CGrids=[];
CGrids=loadCGridData(obj,CompGrids,CGrids,[]);

end

function GridList=loadCGridData(obj,root,GridList,parent)
nchildren=get(root,'ChildCount');
for j=0:nchildren-1
    child=root.getChildAt(j);
    name=child.getValue();
    name=char(name(2));
    GridList.(name).X0=obj.getValue('X0',name);
    GridList.(name).Y0=obj.getValue('Y0',name);
    GridList.(name).DX=obj.getValue('Dx',name);
    GridList.(name).DY=obj.getValue('Dy',name);
    GridList.(name).XLength=obj.getValue('X Length',name);
    GridList.(name).YLength=obj.getValue('Y Length',name);
    GridList.(name).NX=GridList.(name).XLength/GridList.(name).DX;
    GridList.(name).NY=GridList.(name).YLength/GridList.(name).DY;
    GridList.(name).Angle=obj.getValue('Angle',name);
    GridList.(name).parent=parent;
    if get(child,'ChildCount')>0
        nested=[];
        nested=loadCGridData(obj,child,nested,name);
        lnest=fieldnames(nested);
        GridList.(name).nested={};
        for k=1:length(lnest)
            if strcmp(nested.(lnest{k}).parent,name)
                GridList.(name).nested={GridList.(name).nested{:} lnest{k}};
            end
            GridList.(lnest{k})=nested.(lnest{k});
        end
    else
        GridList.(name).nested=[];
    end
    
end
end